package com.bjfu.gmms.servlet;

import com.bjfu.gmms.MyBatisUtil;
import com.bjfu.gmms.mapper.ExamScoreMapper;
import com.bjfu.gmms.mapper.StudentExamViewMapper;
import com.bjfu.gmms.model.ExamScore;
import com.bjfu.gmms.model.StudentExamView;
import com.bjfu.gmms.pojo.ExamInfo;
import com.bjfu.gmms.service.StudentExamViewService;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

@WebServlet("/enterStudentScore")
public class EnterStudentScoreServlet extends HttpServlet {



    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        SqlSession sqlSession = MyBatisUtil.getSqlSession("development");
        int studentId = Integer.parseInt(request.getParameter("studentId"));
        StudentExamViewMapper mapper = sqlSession.getMapper(StudentExamViewMapper.class);
        // 调用存储过程查询该学生的考试科目信息
        List<StudentExamView> studentExamInfo = mapper.getStudentExamInfo(studentId);

        // 将查询结果存入请求属性中，转发到 JSP 页面
        request.setAttribute("studentExamInfo", studentExamInfo);
        request.getRequestDispatcher("enterStudentScore.jsp").forward(request, response);
    }

}
